package net.homeip.jcperera.webinfo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.inject.Named;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import net.homeip.jcperera.nu.model.entity.PersistentEntity;

@Entity
@Table(name = WebInfoPattern.tableName)
@Named(WebInfoPattern.componentName)
@Inheritance(strategy = InheritanceType.JOINED)
public class WebInfoPattern extends PersistentEntity implements Serializable
{
    private static final long  serialVersionUID = -4728774115910367107L;

    // CoreBase properties, for easy use from other components, as well as logging
    public static final int    runtimeLevel     = 5;
    public static final String moduleName       = "webinfo";
    public static final String componentName    = "webinfo_webinfopattern";

    // All persistent entities should specify a table name
    public static final String tableName        = "WEB_INFO_PATTERN";

    @OneToMany(cascade=CascadeType.ALL,mappedBy="pattern")
    private Set<WebInfoValue> webinfovalues = new HashSet<WebInfoValue>();
    
    @ManyToOne
    @JoinColumn(name="SITE", nullable=false)
    private WebInfoSite        site;

    @Basic
    @Column(name = "XSLPATTERN")
    private String             xslPattern       = "";

    @Basic
    @Column(name = "FORMAT")
    private String             format           = "";

    @Basic
    @Column(name = "FIELDNAME")
    private String             fieldName        = "";

    @Basic
    @Column(name = "ISPRIMARY")
    private Boolean            isPrimary        = false;

    public WebInfoSite getSite()
    {
        return site;
    }

    public void setSite(WebInfoSite site)
    {
        this.site = site;
    }

    public String getXslPattern()
    {
        return xslPattern;
    }

    public void setXslPattern(String xslPattern)
    {
        this.xslPattern = xslPattern;
    }

    public String getFormat()
    {
        return format;
    }

    public void setFormat(String format)
    {
        this.format = format;
    }

    public String getFieldName()
    {
        return fieldName;
    }

    public void setFieldName(String fieldName)
    {
        this.fieldName = fieldName;
    }

    public Boolean getIsPrimary()
    {
        return isPrimary;
    }

    public void setIsPrimary(Boolean isPrimary)
    {
        this.isPrimary = isPrimary;
    }

    public Set<WebInfoValue> getWebinfovalues()
    {
        return webinfovalues;
    }
}
